﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace teach
{
    /// <summary>
    /// CarPics question
    /// Show an image and ask for the orthograph
    /// </summary>
    public class CarPics : Question
    {
        public CarPics()
        {
            m_message = "Quel est le modèle?";
        }

        public override object Answer
        {
            get
            {
                return Properties["car"];
            }
        }

        public override bool CheckAnswer(object userAnswer)
        {
            bool success = (userAnswer.ToString().ToLower().Trim() == Answer.ToString().ToLower());
            if (success == false && Properties.ContainsKey("car2"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car2"].ToString().ToLower());
            }
            if (success == false && Properties.ContainsKey("car3"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car3"].ToString().ToLower());
            }
            if (success == false && Properties.ContainsKey("car4"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car4"].ToString().ToLower());
            }
            if (success == false && Properties.ContainsKey("car5"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car5"].ToString().ToLower());
            }
            if (success == false && Properties.ContainsKey("car6"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car6"].ToString().ToLower());
            }
            if (success == false && Properties.ContainsKey("car7"))
            {
                success = (userAnswer.ToString().Trim().ToLower() == Properties["car7"].ToString().ToLower());
            }
            return success;
        }

        public override void GenerateValues(Preference pref)
        {
            this.Timeout = pref.Timeout * 1000;
        }
    }
}